<!doctype html>
<html>

	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="css/mui.css" rel="stylesheet" />
		<link href="css/frozenui/frozenui.css" rel="stylesheet" />

	</head>

	<body>


		<div class="mui-input-group">
			<div class="ui-form ui-border-t">
				<form action="">
					<div class="ui-form-item ui-border-b">
						<label>
							立马注册
						</label>
					</div>
					<div class="mui-input-row">
						<label>用户名</label>
						<input type="text" class="mui-input-clear" placeholder="请输入用户名" id="user">
					</div>
					<div class="mui-input-row">
						<label>密码</label>
						<input type="password" class="mui-input-password" placeholder="请输入密码" id="password">
					</div>
					<div class="mui-input-row">
						<label>同意用户协议</label>
						<div class="mui-switch mui-active">
							<div class="mui-switch-handle"></div>
						</div>
					</div>
					<div class="mui-button-row">

						<button class="ui-btn-lg" id="registerbtn">
							注册
						</button>
					</div>

			</div>
			</form>
		</div>

		</div>

		<script src="js/mui.js"></script>
		<script type="text/javascript">


			mui.plusReady(function() {


				document.getElementById('registerbtn').addEventListener('tap', function() {
					var user = document.getElementById("user").value;
					var password = document.getElementById("password").value;
					mui.ajax('http://192.168.124.5:5000/register', {
						data: {
							user: user,
							password: password
						},
						dataType: "text",
						type: 'post', //HTTP请求类型
						success: function(data) {
							//服务器返回响应，根据响应结果，分析是否登录成功；
							console.log(data)
							if (data == "True") {
								plus.webview.show("login");
								plus.webview.hide("register");
								mui.toast("注册成功")
							} else {
								mui.toast("用户名重复");
							}
						},
						error: function(xhr, type, errorThrown) {
							//异常处理；
							console.log(type)
							mui.toast("无法连接服务器");
						}
					});
				});

			});
		</script>
	</body>

</html>
